﻿@model TuanAnhPersonalWeb.Models.ImageModel 

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<h2>Create New Images To Gallery</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
 
        
        <table>
        <tr>
        <td valign="top">
        <div class="editor-label">
            @Html.LabelFor(model => model.IMAGE_DIR)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.IMAGE_DIR, new { id = "imgdir", @readonly = "true" })
            @Html.ValidationMessageFor(model => model.IMAGE_DIR)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IMAGE_THUMB)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.IMAGE_THUMB, new { id = "thumbdir" ,@readonly="true" })
            @Html.ValidationMessageFor(model => model.IMAGE_THUMB)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IMAGE_DESCRIPTION)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.IMAGE_DESCRIPTION)
            @Html.ValidationMessageFor(model => model.IMAGE_DESCRIPTION)
        </div>
         <div class="editor-label">
            @Html.LabelFor(model => model.ALBUM_ID)
        </div>
        <div class="editor-field">
          @Html.DropDownListFor(model => model.ALBUM_ID, ViewData["Album"] as SelectList,"Chọn Album", new { style = "width:160px", id="Album_" })
           @Html.ValidationMessageFor(model => model.ALBUM_ID)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
        </td>
        <td style="width:100%">

        <script type="text/javascript">
            var finder = new CKFinder();
            finder.selectActionFunction = ShowFileInfo;
            finder.basePath = '/ckfinder/';
            finder.create();
            config.defaultDisplayFilename = true;
            function ShowFileInfo(fileUrl, data) {
                //var imgdir = document.getElementById("imgdir").value;
                document.getElementById("imgdir").value = fileUrl;
                var str = fileUrl.toString();
                var a = '/ckfinder/userfiles_thumbs/Images/' + str.substring(26);
                document.getElementById("thumbdir").value = a;
                alert('Add Link Successfully. Please enter description on the left hand side of the screen!.');
            }
                
</script>

</td>
        </tr>
        </table>
    
}
 


<div>
    @Html.ActionLink("Back to List", "Index")
</div>
